package com.mojo;

import com.mojo.pojo.Teacher;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import java.util.Map;

public class TeacherManager implements ApplicationContextAware {

    private ApplicationContext applicationContext;

    //public Object process(Map commandState) {
    //    // grab a new instance of the appropriate Command
    //    Teacher command = createTeacher();
    //    // set the state on the (hopefully brand new) Command instance
    //    return command.execute();
    //}

    protected Teacher createTeacher() {
        // notice the Spring API dependency!
        return this.applicationContext.getBean("teacher", Teacher.class);
    }

    @Override
    public void setApplicationContext(
            ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}